package aps

import glory.xxd.Utils
import org.json.JSONObject

class ChangeBlockC2EController {

    def commentService

    /**
     * <Request>
     <Header>
     <TRANSACTIONID>9c36ccc4-b164-4fd4-8621-6fb1f9c59c1b</TRANSACTIONID>
     <MESSAGENAME>ChangeBlockC2E</MESSAGENAME>
     <USERNAME>PDA</USERNAME>
     </Header>
     <Body class="Body">

     <EQPID>1FS05</EQPID>
     <Block>2</Block>
     <PIECENO>1/2</PIECENO>
     </Body>
     </Request>
     * @return
     */
    def index() {
        def EQPID = params.EQPID ?: ""
        def Block = params.Block ?: ""
        def PIECENO = params.PIECENO ?: ""

        def body = JSONObject.newInstance()
        body.put("EqpId", EQPID)
        body.put("Block", Block)
        body.put("PIECENO", PIECENO)

        String logUUID = Utils.getUUID();
        def header = JSONObject.newInstance()
        header.put("MESSAGENAME", "ChangeBlockC2E")
        header.put("TRANSACTIONID", logUUID)
        header.put("USERNAME", 'PDA')

        def jsonAll = [Header: header, Body: body] //JSONObject.newInstance()
        //        jsonAll.put("Body",body)
        //        jsonAll.put("Header",header)
        def jsonRequest = JSONObject.newInstance()
        jsonRequest.put("Request", jsonAll)

        def json = commentService.getJsonByJsonForTopic2Queue(logUUID, jsonRequest)

        render json
    }
}
